home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Utilities / Remotes / Source / Configure.m < prev    next >
Encoding:
Text File  |  1992-09-23  |  25.8 KB  |  932 lines

  1. /*---------------------------------------------------------------------------
  2. Configure.m -- Copyright (c) 1991 Rex Pruess
  3.  
  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 1, or (at your option)
  7.    any later version.
  8.  
  9.    This program is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.    GNU General Public License for more details.
  13.  
  14.    You should have received a copy of the GNU General Public License
  15.    along with this program; if not, write to the Free Software
  16.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or send
  17.    electronic mail to the the author.
  18.  
  19. This routine loads & displays the configuration window.  It also contains the
  20. methods for handling the user requests generated from within the configuration
  21. window.
  22.  
  23. Rex Pruess <rpruess@umaxc.weeg.uiowa.edu>
  24.  
  25. $Header: /rpruess/apps/Remotes3.0/RCS/Configure.m,v 3.0 92/09/23 21:53:52 rpruess Exp $
  26. -----------------------------------------------------------------------------
  27. $Log:    Configure.m,v $
  28. Revision 3.0  92/09/23  21:53:52  rpruess
  29. Upgraded for NeXT System Release 3.0.
  30.  
  31. Revision 2.0  91/01/22  15:32:00  rpruess
  32. Remotes-2.0 was upgraded for NeXT System Release 2.0 (standard or extended).
  33. Remotes-2.0 supports the NeXT supplied Terminal application and the Stuart
  34. shareware product.
  35.  
  36. Revision 1.2  90/05/17  15:03:17  rpruess
  37. Minor changes to comments.
  38.  
  39. Revision 1.1  90/04/10  14:25:10  rpruess
  40. Initial revision
  41.  
  42. -----------------------------------------------------------------------------*/
  43.  
  44. /* Standard C header files */
  45. #include <libc.h>
  46. #include <stdio.h>
  47. #include <strings.h>
  48.  
  49. /* Configure class header files */
  50. #import "Configure.h"
  51. #import "BoxViewSwitcher.h"
  52. #import "HostListManager.h"
  53.  
  54. /* Appkit header files */
  55. #import <appkit/Application.h>
  56. #import <appkit/Button.h>
  57. #import <appkit/Cell.h>
  58. #import <appkit/Form.h>
  59. #import <appkit/Matrix.h>
  60. #import <appkit/Menu.h>
  61. #import <appkit/PopUpList.h>
  62. #import <appkit/View.h>
  63.  
  64. #import <defaults/defaults.h>
  65.  
  66. @implementation Configure
  67.  
  68. /*---------------------------------------------------------------------------
  69. Create the Configure object.
  70. -----------------------------------------------------------------------------*/
  71. - init
  72. {
  73.    self = [super init];
  74.    [NXApp loadNibSection:"Configure.nib" owner:self withNames:NO];
  75.    [configWindow setMiniwindowIcon:"app"];
  76.  
  77.    configurePUL = [[PopUpList alloc] init];
  78.  
  79.    theBVS = [[BoxViewSwitcher alloc] init];
  80.    [theBVS setBoxView:boxView];
  81.    [theBVS setBoxViewWindow:boxViewWindow];
  82.    [theBVS setControlButton:appsButton];
  83.    [theBVS setDelegate:self];
  84.    
  85.    return self;
  86. }
  87.  
  88. /*---------------------------------------------------------------------------
  89. Initialize the fields in the configuration window.
  90. -----------------------------------------------------------------------------*/
  91. - initConfigWindow:sender
  92. {
  93.    const char     *string;
  94.  
  95.    [configWindow disableDisplay];
  96.  
  97.    /* Clear some fields */
  98.    [buttonForm setStringValue:""];
  99.    [hostForm setStringValue:""];
  100.  
  101.    /* Set user ID form value */
  102.    [idForm setStringValue:NXUserName ()];
  103.  
  104.    /* Unselect autoStart switch */
  105.    [autoStartButton setIntValue:NO];
  106.  
  107.    /* Set protocol/app values */
  108.    [protocolMatrix selectCellWithTag:RLOGIN];
  109.    [self rloginSet:self];
  110.  
  111.    /* Set font form size value */
  112.    string = NXGetDefaultValue ("Terminal", "NXFixedPitchFontSize");
  113.    if (string != NULL)
  114.       [fontForm setStringValue:string];
  115.    else
  116.       [fontForm setStringValue:""];
  117.  
  118.    /* Set font marix value */
  119.    string = NXGetDefaultValue ("Terminal", "NXFixedPitchFont");
  120.    if (strcmp (string, "Courier") == 0) {
  121.       [fontMatrix selectCellWithTag:COURIER];
  122.       [self courierSet:self];
  123.    }
  124.    else {
  125.       [fontMatrix selectCellWithTag:OHLFS];
  126.       [self ohlfsSet:self];
  127.    }
  128.  
  129.    /* Set X & Y default values */
  130.    [xCell setIntValue:XDEFAULT];
  131.    [yCell setIntValue:YDEFAULT];
  132.  
  133.    /* Set columns form value */
  134.    string = NXGetDefaultValue ("Terminal", "Columns");
  135.    if (string != NULL)
  136.       [colsCell setStringValue:string];
  137.  
  138.    /* Set lines form value */
  139.    string = NXGetDefaultValue ("Terminal", "Rows");
  140.    if (string != NULL)
  141.       [linesCell setStringValue:string];
  142.  
  143.    /* Set default Terminal matrix items */
  144.    [self initMatrixFlags:terminalMatrix];
  145.    [[terminalMatrix selectCellWithTag:TTRANSLAT] setIntValue:YES];
  146.    [[terminalMatrix selectCellWithTag:TAUTOWRAP] setIntValue:YES];
  147.    [[terminalMatrix selectCellWithTag:TSCROLLBK] setIntValue:YES];
  148.  
  149.    [terminalMetaMatrix selectCellWithTag:METAESC];
  150.    
  151.    appType = TERMINAL;
  152.    [theBVS selectBoxViewTitle:TERMLAB];
  153.  
  154.    /* Set default Stuart matrix items */
  155.    [self initMatrixFlags:stuartMatrix];
  156.    [[stuartMatrix selectCellWithTag:SSCROLLBK] setIntValue:YES];
  157.    [[stuartMatrix selectCellWithTag:STRANSLAT] setIntValue:YES];
  158.    [[stuartMatrix selectCellWithTag:STERMSPAC] setIntValue:YES];
  159.  
  160.    [stuartMetaMatrix selectCellWithTag:METAESC];
  161.  
  162.    [self launchState:NO];
  163.  
  164.    /* Position cursor to the button form field */
  165.    [buttonForm selectTextAt:0];
  166.  
  167.    [configWindow reenableDisplay];
  168.    [configWindow displayIfNeeded];
  169.    
  170.    return self;
  171. }
  172.  
  173. /*---------------------------------------------------------------------------
  174. Add a host into the internal linked list and into the popup/pulldown lists.
  175. -----------------------------------------------------------------------------*/
  176. - addNewItem:sender
  177. {
  178.    id              aMetaMatrix;
  179.    char            buttonName[MAXPOPLEN + 1];
  180.    char            errMsg[256];
  181.    int             slotNum;     /* Slot position of host in linked list */
  182.    
  183.    if ([self validHostFields:self] != 0)
  184.       return self;
  185.  
  186.    strcpy (buttonName,[buttonForm stringValueAt:0]);
  187.  
  188.    slotNum = [theHLM getHostSlotNum:buttonName];
  189.    if (slotNum >= 0) {
  190.       [buttonForm selectTextAt:0];
  191.  
  192.       strcpy (errMsg, "The button name '%s' is already listed under Remote ");
  193.       strcat (errMsg, "Systems.  If you want to update it, click Change; ");
  194.       strcat (errMsg, "otherwise rename '%s' and click Add.");
  195.  
  196.       NXRunAlertPanel (NULL, errMsg, NULL, NULL, NULL, buttonName, buttonName);
  197.       return self;
  198.    }
  199.  
  200.    if (appType == TERMINAL)
  201.       aMetaMatrix = terminalMetaMatrix;
  202.    else
  203.       aMetaMatrix = stuartMetaMatrix;
  204.    
  205.    slotNum = [theHLM addHost:buttonName
  206.       fullHostName:[hostForm stringValueAt:0]
  207.       loginName:[idForm stringValueAt:0]
  208.       application:appType
  209.       protocol:protocolType
  210.       locX:[xCell intValue]
  211.       locY:[yCell intValue]
  212.       nLines:[linesCell intValue]
  213.       nCols:[colsCell intValue]
  214.       font:fontType
  215.       fontSize:[fontForm intValueAt:0]
  216.       autoStart:[autoStartButton intValue]
  217.       flags:[self getMatrixFlags:self]
  218.       meta:[[aMetaMatrix selectedCell] tag]   
  219.       updateConfigFile:YES];
  220.  
  221.    if (slotNum < 0)
  222.       return self;
  223.  
  224.    /* Insert host into popup & pulldown lists. */
  225.    [theHostsPUL insertItem:buttonName at:slotNum];
  226.    [configurePUL insertItem:buttonName at:slotNum + 1];
  227.  
  228.    [self launchState:YES];
  229.  
  230.    /* Position to button form to indicate success. */
  231.    [buttonForm selectTextAt:0];
  232.    return self;
  233. }
  234.  
  235. /*---------------------------------------------------------------------------
  236. Change the host's values for the specified button.
  237. -----------------------------------------------------------------------------*/
  238. - changeOldItem:sender
  239. {
  240.    id              aMetaMatrix;
  241.    char            buttonName[MAXPOPLEN + 1];
  242.    char            errMsg[256];
  243.    short int       fontNum;
  244.    int             slotNum;     /* Slot position of host in linked list */
  245.  
  246.    if ([self validHostFields:self] != 0)
  247.       return self;
  248.  
  249.    strcpy (buttonName,[buttonForm stringValueAt:0]);
  250.  
  251.    fontNum = [fontForm intValueAt:0];
  252.  
  253.    slotNum = [theHLM getHostSlotNum:buttonName];
  254.    if (slotNum < 0) {
  255.       [buttonForm selectTextAt:0];
  256.  
  257.       strcpy (errMsg, "The button name '%s' is not listed under Remote ");
  258.       strcat (errMsg, "Systems.  If you would like to add '%s' to the ");
  259.       strcat (errMsg, "Remote Systems list, click Add.");
  260.  
  261.       NXRunAlertPanel (NULL, errMsg, NULL, NULL, NULL, buttonName, buttonName);
  262.       return self;
  263.    }
  264.  
  265.    if (appType == TERMINAL)
  266.       aMetaMatrix = terminalMetaMatrix;
  267.    else
  268.       aMetaMatrix = stuartMetaMatrix;
  269.  
  270.    slotNum = [theHLM changeHost:[buttonForm stringValueAt:0]
  271.       fullHostName:[hostForm stringValueAt:0]
  272.       loginName:[idForm stringValueAt:0]
  273.       application:appType
  274.       protocol:protocolType
  275.       locX:[xCell intValue]
  276.       locY:[yCell intValue]
  277.       nLines:[linesCell intValue]
  278.       nCols:[colsCell intValue]
  279.       font:fontType
  280.       fontSize:fontNum
  281.       autoStart:[autoStartButton intValue]
  282.       flags:[self getMatrixFlags:self]
  283.       meta:[[aMetaMatrix selectedCell] tag]];
  284.  
  285.    if (slotNum < 0)
  286.       return self;
  287.  
  288.    [self launchState:YES];
  289.  
  290.    /* Position to button form to indicate success. */
  291.    [buttonForm selectTextAt:0];
  292.  
  293.    return self;
  294. }
  295.  
  296. /*---------------------------------------------------------------------------
  297. Delete the host entry from internal list & popup/pulldown lists.
  298. -----------------------------------------------------------------------------*/
  299. - deleteOldItem:sender
  300. {
  301.    char            buttonName[MAXPOPLEN + 1];
  302.    char            errMsg[256];
  303.    int             slotNum;     /* Slot position of host in linked list */
  304.  
  305.    strcpy (buttonName,[buttonForm stringValueAt:0]);
  306.  
  307.    slotNum = [theHLM getHostSlotNum:buttonName];
  308.    if (slotNum < 0) {
  309.       strcpy (errMsg, "The button name '%s' is not listed under Remote ");
  310.       strcat (errMsg, "Systems.  Nothing has been deleted.");
  311.  
  312.       NXRunAlertPanel (NULL, errMsg, NULL, NULL, NULL, buttonName);
  313.       return self;
  314.    }
  315.  
  316.    if (NXRunAlertPanel (NULL, "OK to delete '%s'?", "OK", "Cancel", NULL,
  317.          buttonName) != NX_ALERTDEFAULT)
  318.       return self;
  319.  
  320.    slotNum = [theHLM deleteHost:slotNum];
  321.  
  322.    if (slotNum < 0)
  323.       return self;
  324.  
  325.    [[theHostsPUL removeItemAt:slotNum] free];
  326.    [[configurePUL removeItemAt:slotNum + 1] free];
  327.  
  328.    if (strcmp (buttonName,[theHostsButton title]) == 0) {
  329.       slotNum--;
  330.       if (slotNum < 0 && [theHLM getNumHosts:sender] > 0)
  331.          slotNum = 0;
  332.       if (slotNum < 0)
  333.          [theHostsButton setTitle:""];
  334.       else
  335.          [theHostsButton setTitle:[theHLM getButtonName:slotNum]];
  336.    }
  337.  
  338.    [self launchState:NO];
  339.  
  340.    /* Position to button form to indicate success. */
  341.    [buttonForm selectTextAt:0];
  342.    return self;
  343. }
  344.  
  345. /*---------------------------------------------------------------------------
  346. Display the host information for this button.
  347. -----------------------------------------------------------------------------*/
  348. - display:sender
  349. {
  350.    char            buttonName[MAXPOPLEN + 1];
  351.    unsigned int    flagValues;
  352.    int             font;
  353.    int             protocol;
  354.    int             slotNum;     /* Slot position of host in linked list */
  355.  
  356.    if ([sender selectedRow] == 0)
  357.       return self;
  358.  
  359.    strcpy (buttonName,[[sender selectedCell] title]);
  360.  
  361.    slotNum = [theHLM getHostSlotNum:buttonName];
  362.  
  363.    if (slotNum < 0) {
  364.       NXRunAlertPanel (NULL, "The button name '%s' is not in the Remotes data base.",
  365.                NULL, NULL, NULL, buttonName);
  366.       return self;
  367.    }
  368.  
  369.    [configWindow disableDisplay];
  370.  
  371.    [autoStartButton setIntValue:[theHLM getAutoStart:slotNum]];
  372.    [buttonForm setStringValue:buttonName at:0];
  373.    [colsCell setIntValue:[theHLM getColumns:slotNum]];
  374.    [fontForm setIntValue:[theHLM getFontSize:slotNum] at:0];
  375.    [hostForm setStringValue:[theHLM getFullHostName:slotNum] at:0];
  376.    [idForm setStringValue:[theHLM getUserID:slotNum] at:0];
  377.    [linesCell setIntValue:[theHLM getLines:slotNum]];
  378.    [xCell setIntValue:[theHLM getX:slotNum]];
  379.    [yCell setIntValue:[theHLM getY:slotNum]];
  380.  
  381.    protocol = [theHLM getProtocolType:slotNum];
  382.    [protocolMatrix selectCellWithTag:protocol];
  383.    if (protocol == TELNET)
  384.       [self telnetSet:self];
  385.    else if (protocol == TN3270)
  386.       [self tn3270Set:self];
  387.    else
  388.       [self rloginSet:self];
  389.    
  390.    appType = [theHLM getAppType:slotNum];
  391.  
  392.    flagValues = [theHLM getFlags:slotNum];
  393.    
  394.    if (appType == STUART) {
  395.       [[stuartMatrix selectCellWithTag:SSTRICTEM] setIntValue:(flagValues & SSTRICTEM)];
  396.       [[stuartMatrix selectCellWithTag:SKEYPAD] setIntValue:(flagValues & SKEYPAD)];
  397.       [[stuartMatrix selectCellWithTag:SSCROLLBK] setIntValue:(flagValues & SSCROLLBK)];
  398.       [[stuartMatrix selectCellWithTag:STRANSLAT] setIntValue:(flagValues & STRANSLAT)];
  399.       [[stuartMatrix selectCellWithTag:SREVERSE] setIntValue:(flagValues & SREVERSE)];
  400.       [[stuartMatrix selectCellWithTag:SKEYBDFOC] setIntValue:(flagValues & SKEYBDFOC)];
  401.       [[stuartMatrix selectCellWithTag:STERMSPAC] setIntValue:(flagValues & STERMSPAC)];
  402.       [[stuartMatrix selectCellWithTag:SMOUSEFOC] setIntValue:(flagValues & SMOUSEFOC)];
  403.       [[stuartMatrix selectCellWithTag:SSOURCEDL] setIntValue:(flagValues & SSOURCEDL)];
  404.       [[stuartMatrix selectCellWithTag:STESTEXIT] setIntValue:(flagValues & STESTEXIT)];
  405.  
  406.       [stuartMetaMatrix selectCellWithTag:[theHLM getMeta:slotNum]];
  407.  
  408.       [theBVS selectBoxViewTitle:STUARTLAB];
  409.    }
  410.    else {
  411.       [[terminalMatrix selectCellWithTag:TTRANSLAT] setIntValue:(flagValues & TTRANSLAT)];
  412.       [[terminalMatrix selectCellWithTag:TKEYPAD] setIntValue:(flagValues & TKEYPAD)];
  413.       [[terminalMatrix selectCellWithTag:TSTRICTEM] setIntValue:(flagValues & TSTRICTEM)];
  414.       [[terminalMatrix selectCellWithTag:TAUTOWRAP] setIntValue:(flagValues & TAUTOWRAP)];
  415.       [[terminalMatrix selectCellWithTag:TSCROLLBK] setIntValue:(flagValues & TSCROLLBK)];
  416.       [[terminalMatrix selectCellWithTag:TAUTOFOCS] setIntValue:(flagValues & TAUTOFOCS)];
  417.       [[terminalMatrix selectCellWithTag:TSOURCEDL] setIntValue:(flagValues & TSOURCEDL)];
  418.  
  419.       [terminalMetaMatrix selectCellWithTag:[theHLM getMeta:slotNum]];
  420.        
  421.       [theBVS selectBoxViewTitle:TERMLAB];
  422.    }
  423.  
  424.    font = [theHLM getFontType:slotNum];
  425.    [fontMatrix selectCellWithTag:font];
  426.    if (font == COURIER)
  427.       [self courierSet:self];
  428.    else
  429.       [self ohlfsSet:self];
  430.  
  431.    [self launchState:YES];
  432.  
  433.    [configWindow reenableDisplay];
  434.    [configWindow displayIfNeeded];
  435.    
  436.    return self;
  437. }
  438.  
  439. /*---------------------------------------------------------------------------
  440. Get the Terminal or Stuart flag values.
  441. -----------------------------------------------------------------------------*/
  442. - (unsigned int)getMatrixFlags:sender
  443. {
  444.    id              aCell;
  445.    id              aMatrix;
  446.    unsigned int    flagValues;
  447.    int             i;
  448.    int             j;
  449.    int             nCols;
  450.    int             nRows;
  451.  
  452.    if (appType == TERMINAL)
  453.       aMatrix = terminalMatrix;
  454.    else
  455.       aMatrix = stuartMatrix;
  456.  
  457.    [aMatrix getNumRows:&nRows numCols:&nCols];
  458.  
  459.    flagValues = 0;
  460.    for (j = 0; j < nCols; j++)
  461.       for (i = 0; i < nRows; i++) {
  462.      aCell = [aMatrix cellAt:i:j];
  463.      if ([aCell isEnabled] && [aCell intValue] == YES) 
  464.         flagValues |= [[aMatrix cellAt:i:j] tag];
  465.       }
  466.  
  467.    return flagValues;
  468. }   
  469.  
  470. /*---------------------------------------------------------------------------
  471. Initialize the flags in the Terminal or Stuart matrix.
  472. -----------------------------------------------------------------------------*/
  473. - initMatrixFlags:aMatrix
  474. {
  475.    id              aCell;
  476.    int             i;
  477.    int             j;
  478.    int             nCols;
  479.    int             nRows;
  480.  
  481.    [aMatrix getNumRows:&nRows numCols:&nCols];
  482.    for (j = 0; j < nCols; j++)
  483.       for (i = 0; i < nRows; i++) {
  484.      aCell = [aMatrix cellAt:i:j];
  485.      if ([aCell isEnabled])
  486.         [aCell setIntValue:NO];
  487.       }
  488.  
  489.    return self;
  490. }
  491.  
  492. /*---------------------------------------------------------------------------
  493. Set configuration values based on chosen application (boxView).
  494. -----------------------------------------------------------------------------*/
  495. - boxViewDidSwitch:sender
  496. {
  497.    if ( strcmp ([[sender boxView] title], STUARTLAB) == 0)
  498.       [self stuart:self];
  499.    else
  500.       [self terminal:self];
  501.    
  502.    return self;
  503. }
  504.  
  505. /*---------------------------------------------------------------------------
  506. Set variables and enable/disable fields based on the application type.
  507. -----------------------------------------------------------------------------*/
  508. - stuart:sender
  509. {
  510.    appType = STUART;
  511.    [self launchState:NO];
  512.    return self;
  513. }
  514.  
  515. - terminal:sender
  516. {
  517.    appType = TERMINAL;
  518.    [self launchState:NO];
  519.    return self;
  520. }
  521.  
  522. /*---------------------------------------------------------------------------
  523. Set variables and enable/disable fields based on the font style.
  524. -----------------------------------------------------------------------------*/
  525. - courierFont:sender
  526. {
  527.    [self courierSet:self];
  528.    [self launchState:NO];
  529.    return self;
  530. }
  531.  
  532. - courierSet:sender
  533. {
  534.    fontType = COURIER;
  535.    return self;
  536. }
  537.  
  538. - ohlfsFont:sender
  539. {
  540.    [self ohlfsSet:self];
  541.    [self launchState:NO];
  542.    return self;
  543. }
  544.  
  545. - ohlfsSet:sender
  546. {
  547.    fontType = OHLFS;
  548.    return self;
  549. }
  550.  
  551. /*---------------------------------------------------------------------------
  552. Set variables and enable/disable fields based on the protocol.
  553. -----------------------------------------------------------------------------*/
  554. - rlogin:sender
  555. {
  556.    [self rloginSet:self];
  557.    [self launchState:NO];
  558.    return self;
  559. }
  560.  
  561. - rloginSet:sender
  562. {
  563.    protocolType = RLOGIN;
  564.    [idForm setEnabled:YES];
  565.    return self;
  566. }
  567.  
  568. - telnet:sender
  569. {
  570.    [self telnetSet:self];
  571.    [self launchState:NO];
  572.    return self;
  573. }
  574.  
  575. - telnetSet:sender
  576. {
  577.    protocolType = TELNET;
  578.    [idForm setEnabled:NO];
  579.    return self;
  580. }
  581.  
  582. - tn3270:sender
  583. {
  584.    [self tn3270Set:self];
  585.    [self launchState:NO];
  586.    return self;
  587. }
  588.  
  589. - tn3270Set:sender
  590. {
  591.    protocolType = TN3270;
  592.    [idForm setEnabled:NO];
  593.    return self;
  594. }
  595.  
  596. /*---------------------------------------------------------------------------
  597. Handle launch request from the configuration window.  Must login to a host.
  598. -----------------------------------------------------------------------------*/
  599. - launch:sender
  600. {
  601.    [theHLM loginToHost:[buttonForm stringValueAt:0] activate:YES];
  602.    return self;
  603. }
  604.  
  605. /*---------------------------------------------------------------------------
  606. Disable the launch button.  This method is connected to some of the boxes
  607. in the configuration window via the Interface Builder.  This method is not
  608. called internally by this program.
  609. -----------------------------------------------------------------------------*/
  610. - launchDisable:sender
  611. {
  612.    [self launchState:NO];
  613.    return self;
  614. }
  615.  
  616. /*---------------------------------------------------------------------------
  617. Enable or disable the launch button.  This routine is called by various
  618. methods within this program.  It provides a single focal point for
  619. controlling the status of the launch button.
  620. -----------------------------------------------------------------------------*/
  621. - launchState:(BOOL) flag 
  622. {
  623.    [launchButton setEnabled:flag];
  624.    launchFlag =flag; return self;
  625. }
  626.  
  627. /*---------------------------------------------------------------------------
  628. The user pressed the menu revert button.
  629. -----------------------------------------------------------------------------*/
  630. - menuRevert:sender
  631. {
  632.    if ([configWindow isKeyWindow] == YES)
  633.       [self initConfigWindow:self];
  634.    return self;
  635. }
  636.  
  637. /*---------------------------------------------------------------------------
  638. Slap that configuration window onto the screen.
  639. -----------------------------------------------------------------------------*/
  640. - showConfigWindow:sender
  641. {
  642.    [configWindow makeKeyAndOrderFront:sender];
  643.    return self;
  644. }
  645.  
  646. /*---------------------------------------------------------------------------
  647. Validate the fields in the configuration window.
  648. -----------------------------------------------------------------------------*/
  649. - (int)validHostFields:sender
  650. {
  651.    int             length;      /* Temporary variable */
  652.    NXSize          screenSize;  /* Screen width/height */
  653.    int             xMin;        /* Minimum X value allowed */
  654.    int             xMax;        /* Maximum X value allowed */
  655.    int             yMin;        /* Minimum Y value allowed */
  656.    int             yMax;        /* Maximum Y value allowed */
  657.  
  658.    /* Button name validation */
  659.    length = strlen ([buttonForm stringValueAt:0]);
  660.    if (length > MAXPOPLEN || length <= 0) {
  661.       [buttonForm selectTextAt:0];
  662.       NXRunAlertPanel (NULL, "Button name length must be between 1 & %d.", NULL, NULL, NULL, MAXPOPLEN);
  663.       return -1;
  664.    }
  665.  
  666.    /* Host name validation */
  667.    length = strlen ([hostForm stringValueAt:0]);
  668.    if (length > HOSTENTRYLEN || length <= 0) {
  669.       [hostForm selectTextAt:0];
  670.       NXRunAlertPanel (NULL, "Hostname length must be between 1 & %d.", NULL, NULL, NULL, HOSTENTRYLEN);
  671.       return -1;
  672.    }
  673.  
  674.    if (index ([hostForm stringValueAt:0], ' ') != 0) {
  675.       [hostForm selectTextAt:0];
  676.  
  677.       if (NXRunAlertPanel (NULL, "There is a blank in the hostname.",
  678.                "OK", "Cancel", NULL, NULL) != NX_ALERTDEFAULT)
  679.       return -1;
  680.    }
  681.  
  682.    /* User ID validation */
  683.    length = strlen ([idForm stringValueAt:0]);
  684.    if (length > MAXIDLEN) {
  685.       [idForm selectTextAt:0];
  686.       NXRunAlertPanel (NULL, "User ID length can not exceed %d.", NULL, NULL, NULL, MAXIDLEN);
  687.       return -1;
  688.    }
  689.  
  690.    if (index ([idForm stringValueAt:0], ' ') != 0) {
  691.       [idForm selectTextAt:0];
  692.       NXRunAlertPanel (NULL, "Blanks are not allowed in user IDs.", NULL, NULL, NULL);
  693.       return -1;
  694.    }
  695.  
  696.    /* Font size validation */
  697.    length = [fontForm intValueAt:0];
  698.    if (length < MINFONTSIZE || length > MAXFONTSIZE) {
  699.       [fontForm selectTextAt:0];
  700.       NXRunAlertPanel (NULL, "Font size must be between %d & %d.", NULL, NULL, NULL, MINFONTSIZE, MAXFONTSIZE);
  701.       return -1;
  702.    }
  703.  
  704.    /* Get the screen size & establish maximum/minimum values allowed. */
  705.    [NXApp getScreenSize:&screenSize];
  706.    xMin = 0;
  707.    xMax = screenSize.width - (screenSize.width *.08);
  708.    yMin = 100;
  709.    yMax = screenSize.height;
  710.  
  711.    /* X validation */
  712.    length = [xCell intValue];
  713.    if (length < xMin || length > xMax) {
  714.       [windowMatrix selectCell:xCell];
  715.       NXRunAlertPanel (NULL, "X position must be between %d & %d pixels.", NULL, NULL, NULL, xMin, xMax);
  716.       return -1;
  717.    }
  718.  
  719.    /* Y validation */
  720.    length = [yCell intValue];
  721.    if (length < yMin || length > yMax) {
  722.       [windowMatrix selectCell:yCell];
  723.       NXRunAlertPanel (NULL, "Y position must be between %d & %d pixels.", NULL, NULL, NULL, yMin, yMax);
  724.       return -1;
  725.    }
  726.  
  727.    length = [linesCell intValue];
  728.    if (length < MINLINES || length > MAXLINES) {
  729.       [windowMatrix selectCell:linesCell];
  730.       NXRunAlertPanel (NULL, "X size (lines) must be between %d & %d.", NULL, NULL, NULL, MINLINES, MAXLINES);
  731.       return -1;
  732.    }
  733.  
  734.    length = [colsCell intValue];
  735.    if (length < MINCOLS || length > MAXCOLS) {
  736.       [windowMatrix selectCell:colsCell];
  737.       NXRunAlertPanel (NULL, "Y size (columns) must be between %d & %d.", NULL, NULL, NULL, MINCOLS, MAXCOLS);
  738.       return -1;
  739.    }
  740.  
  741.    return 0;
  742. }
  743.  
  744. /*---------------------------------------------------------------------------
  745. Text changed in configuration window so disable the launch button.
  746. -----------------------------------------------------------------------------*/
  747. - text:sender isEmpty:(BOOL) flag
  748. {
  749.    [self launchState:NO];
  750.    return self;
  751. }
  752.  
  753. /*---------------------------------------------------------------------------
  754. Establish the outlets.
  755. -----------------------------------------------------------------------------*/
  756. - setAppsButton:anObject
  757. {
  758.    appsButton = anObject;
  759.    return self;
  760. }
  761.  
  762. - setAutoStartButton:anObject
  763. {
  764.    autoStartButton = anObject;
  765.    return self;
  766. }
  767.  
  768. - setButtonForm:anObject
  769. {
  770.    buttonForm = anObject;
  771.    return self;
  772. }
  773.  
  774. - setColsCell:anObject
  775. {
  776.    colsCell = anObject;
  777.    return self;
  778. }
  779.  
  780. - setFontForm:anObject
  781. {
  782.    fontForm = anObject;
  783.    return self;
  784. }
  785.  
  786. - setHostForm:anObject
  787. {
  788.    hostForm = anObject;
  789.    return self;
  790. }
  791.  
  792. - setIdForm:anObject
  793. {
  794.    idForm = anObject;
  795.    return self;
  796. }
  797.  
  798. - setLaunchButton:anObject
  799. {
  800.    launchButton = anObject;
  801.    return self;
  802. }
  803.  
  804. - setLinesCell:anObject
  805. {
  806.    linesCell = anObject;
  807.    return self;
  808. }
  809.  
  810. - setXCell:anObject
  811. {
  812.    xCell = anObject;
  813.    return self;
  814. }
  815.  
  816. - setYCell:anObject
  817. {
  818.    yCell = anObject;
  819.    return self;
  820. }
  821.  
  822. - setFontMatrix:anObject
  823. {
  824.    fontMatrix = anObject;
  825.    return self;
  826. }
  827.  
  828. - setProtocolMatrix:anObject
  829. {
  830.    protocolMatrix = anObject;
  831.    return self;
  832. }
  833.  
  834. - setTerminalMatrix:anObject
  835. {
  836.    terminalMatrix = anObject;
  837.    return self;
  838. }
  839.  
  840. - setTerminalMetaMatrix:anObject
  841. {
  842.    terminalMetaMatrix = anObject;
  843.    return self;
  844. }
  845.  
  846. - setStuartMatrix:anObject
  847. {
  848.    stuartMatrix = anObject;
  849.    return self;
  850. }
  851.  
  852. - setStuartMetaMatrix:anObject
  853. {
  854.    stuartMetaMatrix = anObject;
  855.    return self;
  856. }
  857.  
  858. - setWindowMatrix:anObject
  859. {
  860.    windowMatrix = anObject;
  861.    return self;
  862. }
  863.  
  864. - setConfigWindow:anObject
  865. {
  866.    configWindow = anObject;
  867.    return self;
  868. }
  869.  
  870. - setBoxViewWindow:anObject
  871. {
  872.    boxViewWindow = anObject;
  873.    return self;
  874. }
  875.  
  876. - setBoxView:anObject
  877. {
  878.    boxView = anObject;
  879.    return self;
  880. }
  881.  
  882. /*---------------------------------------------------------------------------
  883. Set up the configuration pulldown list and its associated button.
  884. -----------------------------------------------------------------------------*/
  885. - setConfigureButton:anObject
  886. {
  887.    configureButton = anObject;
  888.    return self;
  889. }
  890.  
  891. - initConfigButton:anObject
  892. {
  893.    [configurePUL addItem:"Remote Systems"];
  894.    [theHLM loadPopUpList:configurePUL];
  895.  
  896.    [configureButton setTarget:configurePUL];
  897.    [configureButton setAction:@selector (popUp:)];
  898.  
  899.    NXAttachPopUpList (configureButton, configurePUL);
  900.  
  901.    [configurePUL changeButtonTitle:NO];
  902.    [configureButton setIcon:"pulldown" position:NX_ICONRIGHT];
  903.    [configureButton setAltIcon:"pulldownH"];
  904.  
  905.    [configurePUL setTarget:self];
  906.    [configurePUL setAction:@selector (display:)];
  907.  
  908.    return self;
  909. }
  910. /*---------------------------------------------------------------------------
  911. Messages from Remotes.m result in the execution of these sets.
  912. -----------------------------------------------------------------------------*/
  913. - setHostsButton:anObject
  914. {
  915.    theHostsButton = anObject;
  916.    return self;
  917. }
  918.  
  919. - setHostsPUL:anObject
  920. {
  921.    theHostsPUL = anObject;
  922.    return self;
  923. }
  924.  
  925. - setHLM:anObject
  926. {
  927.    theHLM = anObject;
  928.    return self;
  929. }
  930.  
  931. @end
  932.